<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
          <el-form-item label="心眼垂直距离(cm)">
            <el-input v-model="form.cycz" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="安静血压(mmhg)">
            <el-input v-model="form.ajxy" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="HP抗荷动作血压(mmHg)-无抗荷服">
            <el-input v-model="form.hpxyWf" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="HP抗荷动作血压(mmHg)-有抗荷服">
            <el-input v-model="form.hpxy" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="下肢蹬力检测(合格/不合格)">
            <el-input v-model="form.xzdl" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="左下肢(kg)">
            <el-input v-model="form.zxz" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="右下肢(kg)">
            <el-input v-model="form.yxz" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="持续时间(s)">
            <el-input v-model="form.cxsj" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="HP 动作掌握程度(0:熟练掌握，1:掌握，2:基本掌握，3:不掌握)">
            <el-input v-model="form.hpzw" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="呼吸曲线与呼吸引导曲线同步程度(0:完全同步，1:同步，2:基本同步，3:不同步)">
            <el-input v-model="form.qxtb" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="提高 G值((训练收缩压-安静收缩呀)/心眼距离/1.28)">
            <el-input v-model="form.g" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="提高 G值无抗荷服((训练收缩压-安静收缩呀)/心眼距离/1.28)">
            <el-input v-model="form.gWf" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="评定结果(0:优秀，1:良好，2:合格，3:不合格)">
            <el-input v-model="form.result" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="建议">
            <el-input v-model="form.jy" style="width: 370px;" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="cycz" label="心眼垂直距离(cm)" />
        <el-table-column prop="ajxy" label="安静血压(mmhg)" />
        <el-table-column prop="hpxyWf" label="HP抗荷动作血压(mmHg)-无抗荷服" />
        <el-table-column prop="hpxy" label="HP抗荷动作血压(mmHg)-有抗荷服" />
        <el-table-column prop="xzdl" label="下肢蹬力检测(合格/不合格)" />
        <el-table-column prop="zxz" label="左下肢(kg)" />
        <el-table-column prop="yxz" label="右下肢(kg)" />
        <el-table-column prop="cxsj" label="持续时间(s)" />
        <el-table-column prop="hpzw" label="HP 动作掌握程度(0:熟练掌握，1:掌握，2:基本掌握，3:不掌握)" />
        <el-table-column prop="qxtb" label="呼吸曲线与呼吸引导曲线同步程度(0:完全同步，1:同步，2:基本同步，3:不同步)" />
        <el-table-column prop="g" label="提高 G值((训练收缩压-安静收缩呀)/心眼距离/1.28)" />
        <el-table-column prop="gWf" label="提高 G值无抗荷服((训练收缩压-安静收缩呀)/心眼距离/1.28)" />
        <el-table-column prop="result" label="评定结果(0:优秀，1:良好，2:合格，3:不合格)" />
        <el-table-column prop="jy" label="建议" />
        <el-table-column v-if="checkPer(['admin','trainKhdz:edit','trainKhdz:del'])" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudTrainKhdz from '@/api/trainKhdz'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

const defaultForm = { id: null, trainId: null, trainItemId: null, cycz: null, ajxy: null, hpxyWf: null, hpxy: null, xzdl: null, zxz: null, yxz: null, cxsj: null, hpzw: null, qxtb: null, g: null, gWf: null, result: null, jy: null }
export default {
  name: 'TrainKhdz',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({ title: 'HP抗荷动作训练', url: 'api/trainKhdz', idField: 'id', sort: 'id,desc', crudMethod: { ...crudTrainKhdz }})
  },
  data() {
    return {
      permission: {
        add: ['admin', 'trainKhdz:add'],
        edit: ['admin', 'trainKhdz:edit'],
        del: ['admin', 'trainKhdz:del']
      },
      rules: {
      }    }
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
